{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns\n",
    "\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 61878 entries, 0 to 61877\n",
      "Data columns (total 95 columns):\n",
      "id         61878 non-null int64\n",
      "feat_1     61878 non-null int64\n",
      "feat_2     61878 non-null int64\n",
      "feat_3     61878 non-null int64\n",
      "feat_4     61878 non-null int64\n",
      "feat_5     61878 non-null int64\n",
      "feat_6     61878 non-null int64\n",
      "feat_7     61878 non-null int64\n",
      "feat_8     61878 non-null int64\n",
      "feat_9     61878 non-null int64\n",
      "feat_10    61878 non-null int64\n",
      "feat_11    61878 non-null int64\n",
      "feat_12    61878 non-null int64\n",
      "feat_13    61878 non-null int64\n",
      "feat_14    61878 non-null int64\n",
      "feat_15    61878 non-null int64\n",
      "feat_16    61878 non-null int64\n",
      "feat_17    61878 non-null int64\n",
      "feat_18    61878 non-null int64\n",
      "feat_19    61878 non-null int64\n",
      "feat_20    61878 non-null int64\n",
      "feat_21    61878 non-null int64\n",
      "feat_22    61878 non-null int64\n",
      "feat_23    61878 non-null int64\n",
      "feat_24    61878 non-null int64\n",
      "feat_25    61878 non-null int64\n",
      "feat_26    61878 non-null int64\n",
      "feat_27    61878 non-null int64\n",
      "feat_28    61878 non-null int64\n",
      "feat_29    61878 non-null int64\n",
      "feat_30    61878 non-null int64\n",
      "feat_31    61878 non-null int64\n",
      "feat_32    61878 non-null int64\n",
      "feat_33    61878 non-null int64\n",
      "feat_34    61878 non-null int64\n",
      "feat_35    61878 non-null int64\n",
      "feat_36    61878 non-null int64\n",
      "feat_37    61878 non-null int64\n",
      "feat_38    61878 non-null int64\n",
      "feat_39    61878 non-null int64\n",
      "feat_40    61878 non-null int64\n",
      "feat_41    61878 non-null int64\n",
      "feat_42    61878 non-null int64\n",
      "feat_43    61878 non-null int64\n",
      "feat_44    61878 non-null int64\n",
      "feat_45    61878 non-null int64\n",
      "feat_46    61878 non-null int64\n",
      "feat_47    61878 non-null int64\n",
      "feat_48    61878 non-null int64\n",
      "feat_49    61878 non-null int64\n",
      "feat_50    61878 non-null int64\n",
      "feat_51    61878 non-null int64\n",
      "feat_52    61878 non-null int64\n",
      "feat_53    61878 non-null int64\n",
      "feat_54    61878 non-null int64\n",
      "feat_55    61878 non-null int64\n",
      "feat_56    61878 non-null int64\n",
      "feat_57    61878 non-null int64\n",
      "feat_58    61878 non-null int64\n",
      "feat_59    61878 non-null int64\n",
      "feat_60    61878 non-null int64\n",
      "feat_61    61878 non-null int64\n",
      "feat_62    61878 non-null int64\n",
      "feat_63    61878 non-null int64\n",
      "feat_64    61878 non-null int64\n",
      "feat_65    61878 non-null int64\n",
      "feat_66    61878 non-null int64\n",
      "feat_67    61878 non-null int64\n",
      "feat_68    61878 non-null int64\n",
      "feat_69    61878 non-null int64\n",
      "feat_70    61878 non-null int64\n",
      "feat_71    61878 non-null int64\n",
      "feat_72    61878 non-null int64\n",
      "feat_73    61878 non-null int64\n",
      "feat_74    61878 non-null int64\n",
      "feat_75    61878 non-null int64\n",
      "feat_76    61878 non-null int64\n",
      "feat_77    61878 non-null int64\n",
      "feat_78    61878 non-null int64\n",
      "feat_79    61878 non-null int64\n",
      "feat_80    61878 non-null int64\n",
      "feat_81    61878 non-null int64\n",
      "feat_82    61878 non-null int64\n",
      "feat_83    61878 non-null int64\n",
      "feat_84    61878 non-null int64\n",
      "feat_85    61878 non-null int64\n",
      "feat_86    61878 non-null int64\n",
      "feat_87    61878 non-null int64\n",
      "feat_88    61878 non-null int64\n",
      "feat_89    61878 non-null int64\n",
      "feat_90    61878 non-null int64\n",
      "feat_91    61878 non-null int64\n",
      "feat_92    61878 non-null int64\n",
      "feat_93    61878 non-null int64\n",
      "target     61878 non-null object\n",
      "dtypes: int64(94), object(1)\n",
      "memory usage: 44.8+ MB\n"
     ]
    }
   ],
   "source": [
    "train=pd.read_csv('Otto_FE_train_org.csv')\n",
    "train.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 数据准备"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "y_train=train['target']\n",
    "X_train = train.drop([\"id\", \"target\"], axis=1)\n",
    "\n",
    "feat_names=X_train.columns\n",
    "\n",
    "#sklearn的学习器大多之一稀疏数据输入，模型训练会快很多\n",
    "#查看一个学习器是否支持稀疏数据，可以看fit函数是否支持: X: {array-like, sparse matrix}.\n",
    "#可自行用timeit比较稠密数据和稀疏数据的训练时间\n",
    "from scipy.sparse import csr_matrix\n",
    "X_train=csr_matrix(X_train)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "初始化逻辑回归实例（默认参数）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.linear_model import LogisticRegression\n",
    "lr = LogisticRegression()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 交叉验证  \n",
    "交叉验证用于评估模型性能和进行参数调优（模型选择）  \n",
    "分类任务中交叉验证缺省是采用StratifiedKFold  \n",
    "数据集比较大，采用3折交叉验证"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "logloss of each fold is:  [0.67561851 0.67148229 0.67072495]\n",
      "cv logloss is: 0.6726085836956286\n"
     ]
    }
   ],
   "source": [
    "from sklearn.model_selection import cross_val_score\n",
    "loss = cross_val_score(lr, X_train, y_train, cv=3, scoring='neg_log_loss')\n",
    "\n",
    "print( 'logloss of each fold is: ',-loss)\n",
    "print('cv logloss is:', -loss.mean())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 正则化逻辑回归和参数调优（GridSearchCV+LogisticRegressionCV）"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "logistic回归的需要调整超参数有：C（正则系数，一般在log域（取log后的值）均匀设置候选参数）和正则函数penalty（L2/L1）  \n",
    "目标函数为：J =  C* sum(logloss(f(xi), yi)) +* penalty \n",
    "\n",
    "在sklearn框架下，不同学习器的参数调整步骤相同：\n",
    "1. 设置参数搜索范围\n",
    "2. 生成学习器实例（参数设置）\n",
    "3. 生成GridSearchCV的实例（参数设置）\n",
    "4. 调用GridSearchCV的fit方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "#为了比较GridSearchCV和LogisticRegressionCV，两者用相同的交叉验证数据分割\n",
    "from sklearn.model_selection import StratifiedKFold\n",
    "fold = StratifiedKFold(n_splits=3, shuffle=True, random_state=777)   #数据分割"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## GridSearchCV"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "GridSearchCV(cv=StratifiedKFold(n_splits=3, random_state=777, shuffle=True),\n",
       "       error_score='raise',\n",
       "       estimator=LogisticRegression(C=1.0, class_weight=None, dual=False, fit_intercept=True,\n",
       "          intercept_scaling=1, max_iter=100, multi_class='ovr', n_jobs=1,\n",
       "          penalty='l2', random_state=None, solver='liblinear', tol=0.0001,\n",
       "          verbose=0, warm_start=False),\n",
       "       fit_params=None, iid=True, n_jobs=4,\n",
       "       param_grid={'penalty': ['l1', 'l2'], 'C': [0.001, 0.01, 0.1, 1, 10, 100, 1000]},\n",
       "       pre_dispatch='2*n_jobs', refit=True, return_train_score='warn',\n",
       "       scoring='neg_log_loss', verbose=0)"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.model_selection import GridSearchCV\n",
    "from sklearn.linear_model import LogisticRegression\n",
    "\n",
    "#需要调优的参数\n",
    "# 请尝试将L1正则和L2正则分开，并配合合适的优化求解算法（slover）\n",
    "#tuned_parameters = {'penalty':['l1','l2'],\n",
    "#                   'C': [0.001, 0.01, 0.1, 1, 10, 100, 1000]\n",
    "#                   }\n",
    "penaltys = ['l1','l2']\n",
    "Cs = [0.001, 0.01, 0.1, 1, 10, 100, 1000]\n",
    "tuned_parameters = dict(penalty = penaltys, C = Cs)\n",
    "\n",
    "lr_penalty= LogisticRegression(solver='liblinear')\n",
    "grid= GridSearchCV(lr_penalty, tuned_parameters,cv=fold, scoring='neg_log_loss',n_jobs = 4,)\n",
    "grid.fit(X_train,y_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.6721638860978446\n",
      "{'C': 1, 'penalty': 'l2'}\n"
     ]
    }
   ],
   "source": [
    "print(-grid.best_score_)\n",
    "print(grid.best_params_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "D:\\software\\install\\anaconda\\lib\\site-packages\\sklearn\\utils\\deprecation.py:122: FutureWarning: You are accessing a training score ('mean_train_score'), which will not be available by default any more in 0.21. If you need training scores, please set return_train_score=True\n",
      "  warnings.warn(*warn_args, **warn_kwargs)\n",
      "D:\\software\\install\\anaconda\\lib\\site-packages\\sklearn\\utils\\deprecation.py:122: FutureWarning: You are accessing a training score ('std_train_score'), which will not be available by default any more in 0.21. If you need training scores, please set return_train_score=True\n",
      "  warnings.warn(*warn_args, **warn_kwargs)\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAEKCAYAAADjDHn2AAAABHNCSVQICAgIfAhkiAA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jDHl+v8yEgrN1h4gMwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x28162f7f358>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# plot CV误差曲线\n",
    "test_means = grid.cv_results_[ 'mean_test_score' ]\n",
    "test_stds = grid.cv_results_[ 'std_test_score' ]\n",
    "train_means = grid.cv_results_[ 'mean_train_score' ]\n",
    "train_stds = grid.cv_results_[ 'std_train_score' ]\n",
    "\n",
    "# plot results\n",
    "n_Cs = len(Cs)\n",
    "number_penaltys = len(penaltys)\n",
    "test_scores = np.array(test_means).reshape(n_Cs,number_penaltys)\n",
    "train_scores = np.array(train_means).reshape(n_Cs,number_penaltys)\n",
    "test_stds = np.array(test_stds).reshape(n_Cs,number_penaltys)\n",
    "train_stds = np.array(train_stds).reshape(n_Cs,number_penaltys)\n",
    "\n",
    "x_axis = np.log10(Cs)\n",
    "for i, value in enumerate(penaltys):\n",
    "    #pyplot.plot(log(Cs), test_scores[i], label= 'penalty:'   + str(value))\n",
    "    plt.errorbar(x_axis, -test_scores[:,i], yerr=test_stds[:,i] ,label = penaltys[i] +' Test')\n",
    "    plt.errorbar(x_axis, -train_scores[:,i], yerr=train_stds[:,i] ,label = penaltys[i] +' Train')\n",
    "    \n",
    "plt.legend()\n",
    "plt.xlabel( 'log(C)' )                                                                                                      \n",
    "plt.ylabel( 'logloss' )\n",
    "plt.savefig('LogisticGridSearchCV_C.png' )\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "lr_best = grid.best_estimator_"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## LogisticRegressionCV"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<font color='red'> L1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "LogisticRegressionCV(Cs=[0.001, 0.01, 0.1, 1, 10, 100, 1000],\n",
       "           class_weight=None,\n",
       "           cv=StratifiedKFold(n_splits=3, random_state=777, shuffle=True),\n",
       "           dual=False, fit_intercept=True, intercept_scaling=1.0,\n",
       "           max_iter=100, multi_class='ovr', n_jobs=4, penalty='l1',\n",
       "           random_state=None, refit=True, scoring='neg_log_loss',\n",
       "           solver='liblinear', tol=0.0001, verbose=0)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.linear_model import LogisticRegressionCV\n",
    "\n",
    "Cs = [1e-3, 1e-2, 1e-1, 1, 10, 100, 1000]\n",
    "#nCs = 9  #Cs values are chosen in a logarithmic scale between 1e-4 and 1e4.\n",
    "\n",
    "# 大量样本（6W+）、高维度（93），L1正则 --> 可选用saga优化求解器(0.19版本新功能)\n",
    "#LogisticRegressionCV比GridSearchCV快\n",
    "lrcv_L1 = LogisticRegressionCV(Cs=Cs, cv = fold, scoring='neg_log_loss', penalty='l1', solver='liblinear', multi_class='ovr',n_jobs=4)\n",
    "lrcv_L1.fit(X_train, y_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAEKCAYAAADjDHn2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAHeBJREFUeJzt3XtwXGeZ5/Hv07raUnxVt/EttmwrrTiBmMRxwBZGHQZImNmEgQQI1CwB71JTM9SwfwxLZtmCmlCzwxTFFDsz7G4yGzNhiiQLBJgMBBLAkh3HOLEc4sQ32fIllrAdSVasWHZk6/LsH90msiKrW3Ifnb78PlUqd58+5+g5ia2fzvu+533N3RERERlPJOwCRE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IOZjfdvsALon0RtIlmnsBCZnC3Ax1MLz0SB9cDzJJe1/Giq72IeyYn3LtoHrABw90NAC/DXqVlQMbO6i2t4mNlcoMvdB6bqgkTGo7AQmZwfAy8Bu4BNwH9NNTs9TnIdi90k1w1/DuhNHfMzLg2P/wS8DWgzs5eBf+bN9S4SQN7NgiqFS7POimSZmVW7e1/q7uB5YJ27n0ytN9CUen+5ju2L5/gR8Fd5vP64FBiNhhLJvp+mFqQpB76WuuPA3d8ws6+SXIf72OUOTi2U9BMFheQS3VmIiEha6rMQEZG0FBYiIpKWwkJERNJSWIiISFoKCxERSUthISIiaf1/5i4ocHOA+IYAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x2816348b198>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# scores_：dict with classes as the keys, and the values as the grid of scores obtained during cross-validating each fold,\n",
    "# Each dict value has shape (n_folds, len(Cs))\n",
    "Cs = [1e-3, 1e-2, 1e-1, 1, 10, 100, 1000]\n",
    "n_Cs = len(Cs)\n",
    "n_classes = 9\n",
    "scores =  np.zeros((n_classes,n_Cs))\n",
    "\n",
    "for j in range(n_classes):\n",
    "        scores[j][:] = np.mean(lrcv_L1.scores_['Class_'+ str(j+1)],axis = 0)\n",
    "    \n",
    "logloss_mean = -np.mean(scores, axis = 0)\n",
    "plt.plot(np.log10(Cs), logloss_mean.reshape(n_Cs,1)) \n",
    "#plt(np.log10(reg.Cs)*np.ones(3), [0.28, 0.29, 0.30])\n",
    "plt.xlabel('log(C)')\n",
    "plt.ylabel('logloss')\n",
    "plt.show()\n",
    "\n",
    "#print ('C is:',lr_cv.C_)  #对多类分类问题，每个类别的分类器有一个C"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0.17636839, 0.14007944, 0.13544277, 0.13543766, 0.13552153,\n",
       "       0.135537  , 0.13554122])"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "logloss_mean"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 0.13543766325817497\n"
     ]
    }
   ],
   "source": [
    "best_C = np.argmin(logloss_mean)\n",
    "best_score = np.min(logloss_mean)\n",
    "print (Cs[best_C], best_score)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<font color='red'> L2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "LogisticRegressionCV(Cs=[0.001, 0.01, 0.1, 1, 10, 100, 1000],\n",
       "           class_weight=None,\n",
       "           cv=StratifiedKFold(n_splits=3, random_state=777, shuffle=True),\n",
       "           dual=False, fit_intercept=True, intercept_scaling=1.0,\n",
       "           max_iter=100, multi_class='ovr', n_jobs=4, penalty='l2',\n",
       "           random_state=None, refit=True, scoring='neg_log_loss',\n",
       "           solver='liblinear', tol=0.0001, verbose=0)"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lrcv_L2 = LogisticRegressionCV(Cs=Cs, cv = fold, scoring='neg_log_loss', penalty='l2', solver='liblinear', multi_class='ovr',n_jobs=4)\n",
    "lrcv_L2.fit(X_train, y_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAEKCAYAAADjDHn2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAHgNJREFUeJzt3XtwXOWZ5/Hv07rakm+yuh1fhGUb0cJOggPC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LS/TG3789T2IllBl7kik/MRYDVwFcknmreb2SbgBqAWeAcQIzn89f2pfW4AHky9XkXyafShixz/BeDaQCoXmQRdWYhMTiPwYGrEz1eAjSS/3BuBf3X3YXc/BjSP2Gch0J3JwVMhci41OY9I6BQWIpMz1vDj460HeB0oT73eBVxlZuP9GywD+idRm8iUU1iITM4m4OOpiWeiwDrgaZLTWn40de9iAcmB987bA1wO4O4vAa3A36RGQcXM6s7P4WFm84Fudx+YrhMSGY/CQmRyHgGeA54FNgD/NdXs9DDJeSxeIDlv+DagN7XPL7kwPP4UeBvQbmbPA//Cm/NdJICcGwVV8pdGnRWZYmZW6e59qauDp4Eb3P1Yar6B5tTyxW5snz/Gz4C/zuH5xyXPqDeUyNT7RWpCmlLg66krDtz9dTP7Gsl5uA9fbOfUREk/V1BINtGVhYiIpKV7FiIikpbCQkRE0lJYiIhIWgoLERFJS2EhIiJpKSxERCSt/w9/7iewpkXUkgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x21fd01539e8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "Cs = [1e-3, 1e-2, 1e-1, 1, 10, 100, 1000]\n",
    "n_Cs = len(Cs)\n",
    "n_classes = 9\n",
    "scores =  np.zeros((n_classes,n_Cs))\n",
    "\n",
    "for j in range(n_classes):\n",
    "        scores[j][:] = np.mean(lrcv_L2.scores_['Class_'+ str(j+1)],axis = 0)\n",
    "    \n",
    "logloss_mean_l2 = -np.mean(scores, axis = 0)\n",
    "plt.plot(np.log10(Cs), logloss_mean.reshape(n_Cs,1)) \n",
    "#plt(np.log10(reg.Cs)*np.ones(3), [0.28, 0.29, 0.30])\n",
    "plt.xlabel('log(C)')\n",
    "plt.ylabel('logloss')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0.14668809, 0.13635492, 0.13540789, 0.13544958, 0.13552072,\n",
       "       0.13553591, 0.1355377 ])"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "logloss_mean_l2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.1 0.13540789390613064\n"
     ]
    }
   ],
   "source": [
    "best_C_l2 = np.argmin(logloss_mean_l2)\n",
    "best_score_l2 = np.min(logloss_mean_l2)\n",
    "print (Cs[best_C_l2], best_score_l2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pickle\n",
    "\n",
    "pickle.dump(grid.best_estimator_, open(\"Otto_L2_org.pkl\", 'wb'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-2.94039351e-02, -1.50721134e-01, -1.19649563e-01,\n",
       "        -5.02679193e-02,  1.57906486e-01,  2.58553077e-01,\n",
       "         8.56408924e-02,  2.65900869e-02, -2.99714054e-01,\n",
       "         2.57018032e-02, -4.68805907e-01,  2.90319293e-02,\n",
       "        -1.40209817e-01, -3.53222329e-01, -4.43778402e-01,\n",
       "        -3.41381830e-02,  2.12957972e-01,  1.01152888e-01,\n",
       "        -1.50522194e-01,  8.41740106e-02, -1.01803767e-02,\n",
       "         4.40955720e-02,  1.55958402e-01,  7.35932316e-02,\n",
       "        -3.41809925e-01, -7.72275933e-02, -5.55630579e-02,\n",
       "         9.56246278e-02, -1.51173009e-01,  1.38298687e-01,\n",
       "        -4.69808376e-01,  3.79787917e-02, -2.23462744e-01,\n",
       "        -3.13300003e-01, -1.91315062e-01, -6.79913027e-02,\n",
       "         2.72343988e-01, -6.53705194e-02, -4.48070492e-02,\n",
       "        -3.89920281e-01, -2.41651716e-01, -2.31398697e-01,\n",
       "        -1.04512886e+00,  1.09792311e-01, -1.27538568e-01,\n",
       "        -1.09614275e-01, -1.43457605e-01,  1.47342788e-02,\n",
       "         3.68716831e-02, -3.31241975e-01,  5.13023172e-02,\n",
       "         1.50837627e-02,  8.13873070e-02, -4.05507110e-03,\n",
       "         1.24799285e-01, -1.10821416e-01, -1.70310282e-01,\n",
       "        -5.68665485e-01, -9.91913432e-02, -1.72585507e-01,\n",
       "         1.88968069e-01,  3.73746023e-02, -5.11615013e-02,\n",
       "        -6.34941912e-02, -1.05302880e-02,  1.67416061e-01,\n",
       "         6.14415958e-02, -2.02014707e-01, -2.35453410e-01,\n",
       "         1.59125995e-01,  7.27661086e-02, -1.89144803e-01,\n",
       "        -4.07997471e-02, -1.77486915e-01, -1.82711483e-01,\n",
       "         9.07633832e-02,  2.61419325e-01, -1.92925155e-02,\n",
       "         8.33897230e-02,  3.68477280e-02,  3.62657771e-01,\n",
       "        -2.84990640e-01,  2.89269447e-03,  8.85534240e-02,\n",
       "         3.99794368e-02, -1.42111633e-01, -3.69627746e-02,\n",
       "        -6.66708225e-02, -6.79010218e-02, -2.27032059e-01,\n",
       "        -7.28460723e-02,  8.27186220e-02, -1.96216219e-01],\n",
       "       [-1.77363468e-03, -2.10880966e-01, -9.73862849e-02,\n",
       "         9.99796726e-03,  1.17519921e-01,  9.19576888e-02,\n",
       "        -1.30561010e-01, -9.52049945e-02,  2.80085189e-02,\n",
       "         2.65188922e-02, -3.20814787e-01,  2.00120665e-01,\n",
       "        -2.19805242e-01,  3.53520917e-02,  3.20915687e-02,\n",
       "         4.94486222e-02, -3.92597464e-01,  2.04269668e-02,\n",
       "        -1.63891205e-01, -1.25372541e-01,  5.58260698e-02,\n",
       "        -2.93099849e-02, -3.23546734e-01,  3.97969254e-02,\n",
       "         8.96636215e-02, -6.95188213e-01, -2.11679826e-01,\n",
       "        -1.15077269e-01, -4.12424780e-01, -4.31520048e-01,\n",
       "        -2.66281278e-02, -8.45860334e-02,  1.88718519e-01,\n",
       "        -1.86902528e-01, -6.91610767e-02, -3.30716164e-01,\n",
       "        -3.65464681e-02,  4.29830779e-02, -1.23453886e-01,\n",
       "         3.51900162e-02, -4.08808467e-01, -3.86992495e-01,\n",
       "        -6.54800621e-03, -1.37359814e-02, -9.33710544e-03,\n",
       "        -1.31559098e-01, -2.90998152e-01,  1.45959697e-01,\n",
       "         1.64847446e-02, -9.15100468e-02, -4.04441837e-01,\n",
       "         2.34713312e-02, -1.96788585e-01,  4.30623364e-02,\n",
       "        -8.14391613e-02, -1.19115967e-01, -4.99015793e-01,\n",
       "        -1.30342113e-01, -2.78672039e-01, -2.83728363e-01,\n",
       "        -2.24380213e-01, -1.88435712e-02,  1.24168200e-01,\n",
       "         4.53278296e-02,  4.91303787e-02,  6.35856188e-02,\n",
       "         2.64051607e-02, -4.84399052e-01, -1.07944146e-01,\n",
       "        -8.61974161e-03, -3.37265391e-01,  6.76940827e-02,\n",
       "        -4.58546921e-02,  1.83529699e-02, -3.34234296e-01,\n",
       "        -8.26334541e-02,  3.23335872e-01, -3.67433771e-01,\n",
       "        -2.02959876e-01, -1.15204974e-01, -1.93952373e-01,\n",
       "         3.53476459e-02, -3.07322819e-02, -7.37324670e-01,\n",
       "        -1.01569756e-02,  4.53391851e-03,  4.38070151e-02,\n",
       "        -3.51013611e-02,  2.21661168e-02, -2.36963004e-01,\n",
       "        -3.68194165e-01,  8.20487642e-02, -5.25417398e-02],\n",
       "       [-7.89229035e-02, -6.41925384e-02, -7.84643135e-02,\n",
       "        -4.06987017e-02, -2.12519256e-01, -6.41080582e-02,\n",
       "        -1.89420319e-01, -6.43361702e-02,  5.74190483e-02,\n",
       "        -5.01082010e-02, -2.44905680e-01, -5.31525004e-02,\n",
       "         3.00083840e-03,  4.52036735e-02,  2.04063309e-02,\n",
       "         7.05730590e-02, -3.17172359e-01, -5.21522552e-02,\n",
       "        -4.23372496e-02, -1.33565374e-01,  7.30290502e-02,\n",
       "        -5.51257072e-02,  1.63976766e-02,  3.87195912e-02,\n",
       "        -1.00635600e-02, -5.16155749e-01,  3.00123811e-02,\n",
       "        -1.05754837e-01,  4.87036408e-02,  1.40947307e-01,\n",
       "         6.64861471e-02,  1.04426509e-01, -4.97881353e-02,\n",
       "        -1.26429412e-01, -6.70908968e-02, -4.72062177e-02,\n",
       "        -2.81423150e-02,  6.01851237e-02, -6.64218981e-02,\n",
       "         6.67569324e-02,  1.48780132e-02, -2.31097999e-01,\n",
       "         1.95157350e-01, -3.07554332e-03, -1.09419653e-01,\n",
       "         1.16837511e-02, -4.18641372e-01, -2.93610748e-02,\n",
       "         2.27839668e-02,  6.65632939e-03, -2.48558651e-01,\n",
       "         1.10229974e-02, -5.44949907e-02, -6.10456153e-03,\n",
       "        -1.26710716e-02,  2.94009968e-02, -4.17140600e-01,\n",
       "        -8.16758879e-02, -1.62310473e-01, -8.98516765e-01,\n",
       "        -2.25296491e-01,  2.05538735e-02,  2.46697606e-02,\n",
       "         6.19951231e-02, -6.17593809e-02, -1.08724066e-02,\n",
       "        -8.61851252e-02, -1.03012207e-01, -2.71086495e-01,\n",
       "         3.20815593e-02,  1.18804986e-01, -1.22605467e-02,\n",
       "        -1.79534148e-01, -1.42606873e-01, -2.19048534e-01,\n",
       "        -1.54085675e-01, -4.94922377e-01, -4.24399050e-02,\n",
       "        -4.80908441e-02,  5.09799741e-02, -8.92936441e-02,\n",
       "        -4.08133338e-01,  1.24905387e-01, -6.64538263e-01,\n",
       "         6.63607582e-02,  6.68620774e-02, -7.24697260e-02,\n",
       "         4.57173670e-02,  1.27307308e-01, -1.58575702e-01,\n",
       "        -2.35357432e-01, -7.14362017e-01, -2.48758018e-01],\n",
       "       [ 1.62184895e-01, -2.84746393e-01, -2.27548772e-01,\n",
       "        -2.42366615e-01,  1.28961920e-01,  2.31713198e-02,\n",
       "        -1.59937764e-01, -1.26422836e-02, -1.84867355e-01,\n",
       "         5.80095780e-02, -4.17064681e-01, -2.07790429e-01,\n",
       "         4.29418596e-02,  8.73858335e-03,  9.63422294e-02,\n",
       "        -1.12091216e-02, -3.40319847e-01, -2.38504402e-01,\n",
       "        -7.19453521e-03,  6.70352062e-02, -1.15890540e-01,\n",
       "         4.65929501e-02,  6.98067361e-02, -1.78385697e-01,\n",
       "         1.45717814e-01,  4.10336895e-01,  1.95963931e-02,\n",
       "        -3.30288771e-01, -1.32531091e-01, -2.68212744e-01,\n",
       "        -1.20641986e-01, -9.07508961e-02, -1.93672372e-02,\n",
       "        -1.39970062e-01, -2.76536419e-01, -5.27278115e-03,\n",
       "        -1.65841729e-02, -3.94776128e-02, -2.01813228e-01,\n",
       "         1.69983383e-02, -2.15482914e-02,  7.19367047e-02,\n",
       "         3.99235601e-02,  8.62162485e-02, -5.09719933e-02,\n",
       "        -4.84720105e-03, -6.84784025e-01, -1.71046643e-01,\n",
       "        -2.57278357e-01, -4.11984623e-02, -6.03372294e-01,\n",
       "         2.34517458e-01, -1.71491800e-02, -4.31093395e-02,\n",
       "         3.14781448e-02,  2.44264498e-02, -5.73236872e-01,\n",
       "        -5.68694009e-01, -2.72434549e-01, -4.61941103e-02,\n",
       "        -5.38409971e-01, -2.93660091e-01,  7.36724531e-02,\n",
       "         3.89650697e-03, -1.62367443e-01, -1.22968509e-02,\n",
       "        -1.76585748e-01, -3.70757906e-02, -1.26002356e-02,\n",
       "         8.07828527e-03, -1.92015913e-01, -6.74459482e-03,\n",
       "        -2.03239342e-02,  1.18355850e-02, -8.35840284e-02,\n",
       "        -3.47891787e-01, -4.83579917e-01, -5.07314924e-02,\n",
       "         6.87831424e-02,  1.25847794e-02, -3.18421993e-01,\n",
       "        -3.72107627e-01, -6.19809126e-02, -7.18090947e-01,\n",
       "         7.49170297e-02,  7.03380190e-02,  2.12271957e-01,\n",
       "         5.65436764e-02, -1.07722260e-01, -2.07380563e-01,\n",
       "         3.62216422e-03,  1.54327883e-01, -4.19260172e-01],\n",
       "       [-2.56357720e-01,  2.53635044e-01,  5.02968967e-01,\n",
       "        -1.32478099e-01, -1.66786298e-01, -2.28815030e-01,\n",
       "        -5.12179559e-01,  1.04106624e-01, -1.24344768e-02,\n",
       "        -4.91071029e-01, -1.46486024e+00,  3.80566544e-01,\n",
       "         5.01323881e-02, -4.28013717e-01, -2.32767672e-01,\n",
       "         3.37662019e-02, -1.09605817e+00,  2.38612340e-01,\n",
       "        -9.66215831e-02, -2.33242436e-02, -7.25477454e-01,\n",
       "         2.26558150e-01,  7.49965509e-02, -8.93314235e-02,\n",
       "        -5.38385791e-01, -9.97630115e-01, -3.86209172e-01,\n",
       "        -3.09178643e-01, -5.55475015e-01, -7.22897462e-01,\n",
       "         3.30695057e-01,  1.65110126e-01,  1.89121182e-01,\n",
       "         9.55980759e-01, -1.82130169e-01, -4.91326928e-01,\n",
       "         1.12645283e-01, -1.33821643e-01, -2.80608647e+00,\n",
       "        -1.75086190e-02, -1.04470650e-01, -2.86608771e-01,\n",
       "        -3.36752707e+00,  7.10340152e-02, -4.93963585e-01,\n",
       "        -3.41631126e-01, -9.81278027e-01, -2.84234179e-02,\n",
       "         6.27948319e-02, -5.23284807e-01, -3.40980903e-01,\n",
       "        -1.17460068e+00, -5.89679281e-02, -1.94841763e-01,\n",
       "        -3.05576671e-01, -3.36477028e-01,  4.27976125e-02,\n",
       "        -8.01585411e-01, -1.63873492e+00, -1.13500511e+00,\n",
       "        -1.27771537e-01, -1.85325232e-01, -1.76714879e-01,\n",
       "        -9.77420572e-02, -1.73705602e-01,  1.29800604e-01,\n",
       "        -1.02276432e-01, -3.41737295e-01, -3.05907556e-01,\n",
       "        -1.43558127e-01,  3.50494377e-01, -5.47311308e-01,\n",
       "        -1.13353005e+00, -5.37801274e-02, -1.22954891e+00,\n",
       "        -5.98919044e-01, -7.65928131e-01, -6.16099154e-01,\n",
       "         4.29101855e-03,  1.18179783e-01, -6.53425888e-01,\n",
       "        -4.89545656e-01, -1.76087527e+00, -1.19665237e+00,\n",
       "        -1.85870736e-01, -8.65872238e-01,  1.81243306e-01,\n",
       "        -4.07517819e-01, -2.92236469e-01, -4.42071563e-01,\n",
       "        -4.74986188e-01,  8.82679727e-02, -8.33170350e-03],\n",
       "       [ 6.40330107e-02,  1.02371177e-02,  8.94761672e-02,\n",
       "        -2.45892319e-03, -2.81011907e-01,  9.48490104e-02,\n",
       "        -1.72560807e-01, -6.82252657e-02, -1.68288872e-01,\n",
       "        -5.87662543e-02,  7.46451701e-01, -7.52569329e-02,\n",
       "         1.81708038e-03, -3.24337504e-01, -2.76336960e-01,\n",
       "         1.49842486e-03,  1.43858499e-02,  1.24127627e-01,\n",
       "        -1.36210228e-01, -2.00707732e-02,  2.67254558e-03,\n",
       "         4.75416282e-02,  7.37340531e-02, -1.86160552e-04,\n",
       "        -1.72833737e-01,  3.32145777e-01,  6.69351813e-02,\n",
       "        -4.93318833e-03,  7.02611848e-02, -1.79127642e-01,\n",
       "         9.13115403e-02, -7.61426840e-02, -1.10687516e-01,\n",
       "        -2.82758332e-01, -2.54220495e-01, -7.79000131e-02,\n",
       "        -1.18819953e-01, -9.95900484e-02,  1.21422525e-02,\n",
       "        -2.98373637e-01, -9.04926322e-02,  5.07377091e-01,\n",
       "        -1.16748673e-01,  1.06286543e-01,  3.02631338e-02,\n",
       "         9.86305515e-02,  4.99231309e-02, -9.31880408e-02,\n",
       "         4.04751860e-03,  2.14785994e-02,  2.74001677e-02,\n",
       "        -1.56143743e-01, -3.56188615e-02,  3.49450635e-02,\n",
       "         5.24199897e-02, -1.21534462e-01,  5.57477846e-01,\n",
       "        -1.21745920e-01,  2.45601570e-02,  4.03651697e-01,\n",
       "         3.28236513e-01, -1.94346937e-01, -1.41379832e-02,\n",
       "         8.77380541e-02, -5.45573833e-02,  1.85472835e-02,\n",
       "        -1.60574573e-03, -1.42513374e-01, -1.03843298e-01,\n",
       "        -2.74190244e-02, -1.29719474e-01, -2.59701322e-01,\n",
       "        -5.76958096e-02,  7.25654783e-02, -7.89006624e-02,\n",
       "        -8.43725278e-02, -1.44000301e-01, -3.32677813e-01,\n",
       "         9.74209972e-02, -4.61196953e-03,  8.71346059e-03,\n",
       "         1.07757506e-01, -1.71077859e-02, -2.23581614e-01,\n",
       "        -4.51022107e-02, -3.98545870e-02,  1.05321670e-01,\n",
       "        -1.94081545e-01, -1.45677881e-01, -1.52899431e-01,\n",
       "        -7.77595214e-03,  7.79298509e-02,  3.75079099e-01],\n",
       "       [-1.82720467e-02,  1.13793405e-01, -4.45478251e-02,\n",
       "        -4.05165400e-02, -2.49913383e-01,  3.89551879e-02,\n",
       "        -1.58028551e-02, -1.36414174e-01, -3.10826552e-01,\n",
       "         5.06043648e-02, -1.86894158e-01,  1.40570286e-01,\n",
       "        -1.92095769e-01, -1.51397010e-01, -3.48611111e-01,\n",
       "         1.20509465e-01,  9.96841183e-02, -3.49826900e-02,\n",
       "        -9.68468699e-02, -2.05926305e-02,  2.62668150e-02,\n",
       "        -4.30367542e-02,  3.30148470e-01,  1.72736511e-02,\n",
       "        -1.77690276e-01, -1.99901912e-01, -3.32603755e-01,\n",
       "         1.61530780e-02, -3.22249488e-02, -1.41154261e-01,\n",
       "        -7.54414381e-02,  2.75404180e-01, -6.15062006e-02,\n",
       "        -2.46805877e-01, -6.72455074e-02, -2.16041781e-01,\n",
       "         1.02857394e-01,  1.35281173e-01,  2.00627311e-01,\n",
       "        -2.63585539e-01, -1.59449375e-01, -1.27811730e-01,\n",
       "         1.21794056e-02,  4.20630251e-02,  7.72232112e-02,\n",
       "        -1.20765885e-01,  3.17335732e-02,  3.80571712e-02,\n",
       "         8.13693529e-02,  3.09664447e-01,  6.94320161e-02,\n",
       "         9.49533924e-02, -1.06751663e-01, -4.29847368e-02,\n",
       "         3.89352082e-02,  1.41592584e-01, -3.52757317e-03,\n",
       "        -1.13466194e-01, -4.17698829e-02, -1.21587739e-01,\n",
       "        -3.98616798e-01, -2.09489579e-01,  3.52050620e-03,\n",
       "         3.56062694e-02, -2.53316083e-02,  1.01394095e-01,\n",
       "        -4.42155894e-02, -1.78977588e-01, -1.30199296e-01,\n",
       "         6.62932610e-02,  2.24111487e-02, -1.20644515e-01,\n",
       "        -1.00014634e-01, -4.81690933e-02, -2.25260537e-01,\n",
       "        -6.31420688e-02, -3.47894372e-02, -5.96393012e-02,\n",
       "         5.26622291e-02, -2.76349599e-03,  2.15452613e-01,\n",
       "         2.17528759e-02,  4.93001357e-02, -7.98481703e-01,\n",
       "        -4.87602472e-02,  8.15685505e-02,  1.97482245e-03,\n",
       "        -3.98027820e-02, -1.78043534e-02, -1.05935971e-01,\n",
       "        -1.32171542e-02, -2.28136414e-01, -1.10171037e-01],\n",
       "       [ 6.06574337e-02, -1.82811856e-01, -1.24100014e-01,\n",
       "         3.50173103e-02, -3.16617702e-02,  2.29016447e-02,\n",
       "         1.11250457e-01, -6.33159254e-02, -5.27957998e-02,\n",
       "         9.90992663e-02, -5.28185139e-01,  6.87294612e-02,\n",
       "         8.20813557e-02, -3.28326485e-01, -4.38105634e-01,\n",
       "        -3.97492273e-02, -1.47830488e-01,  4.51050039e-05,\n",
       "         1.81051120e-01,  2.01810526e-01,  1.54985062e-02,\n",
       "         3.37836930e-02, -7.95922530e-02,  1.05273876e-02,\n",
       "        -8.53843040e-02, -2.53008131e-01, -3.52767486e-02,\n",
       "         2.48152668e-01, -3.93801758e-02, -1.14939595e-01,\n",
       "         1.86064177e-01, -1.06866267e-01,  3.21898474e-02,\n",
       "        -2.95894059e-01,  2.79144099e-01, -1.96595038e-01,\n",
       "         3.68349196e-01,  2.18688934e-01, -2.46906911e-01,\n",
       "        -2.85156357e-01,  4.18759806e-02, -2.53971388e-01,\n",
       "        -5.85334046e-01,  6.59961351e-03, -2.36254952e-01,\n",
       "         5.48972599e-02,  2.05612957e-01, -1.68278649e-01,\n",
       "        -6.57553081e-02, -1.38941629e-01,  1.19127093e-01,\n",
       "         5.47607502e-02, -2.06180980e-01,  3.08322261e-02,\n",
       "        -5.28502766e-02, -1.03398215e-01, -1.90962124e-01,\n",
       "         2.01398892e-01, -2.14388103e-01, -3.17825436e-01,\n",
       "        -1.20412839e-01, -2.60844931e-02, -4.78508203e-02,\n",
       "         1.49243244e-02,  1.14193881e-01,  4.32560224e-02,\n",
       "         1.91031735e-02,  4.23603874e-01,  3.52869086e-01,\n",
       "         2.10270284e-02,  2.78473380e-01, -2.20690258e-01,\n",
       "         1.20735674e-01,  8.89039605e-03,  3.45450422e-01,\n",
       "         3.07772781e-02, -3.90394411e-01,  1.60927865e-01,\n",
       "        -1.98689468e-01,  4.98836112e-02,  1.49923378e-01,\n",
       "        -1.49811721e-01,  4.10790579e-02,  1.48846582e-01,\n",
       "        -1.55689186e-01, -4.19635343e-01, -1.71680922e-01,\n",
       "        -1.86916290e-01,  9.62642590e-02,  3.34311409e-01,\n",
       "        -3.76157445e-01, -8.01865085e-02, -6.23578168e-02],\n",
       "       [ 9.02059592e-02, -6.52094968e-02, -4.60715823e-02,\n",
       "        -6.58527946e-02, -1.29105871e-01, -6.78809617e-01,\n",
       "        -1.15778691e-01,  7.21625172e-02, -2.52589915e-01,\n",
       "        -1.41125499e-01, -4.59454044e-01, -1.79700157e-01,\n",
       "         7.85222775e-02, -2.94746586e-01, -3.46132601e-01,\n",
       "         3.40151271e-02,  6.21285858e-02,  6.46766968e-02,\n",
       "        -1.20682458e-01, -1.23989016e-01,  1.96029468e-01,\n",
       "         2.30697603e-01, -2.95774589e-01, -4.94228382e-02,\n",
       "        -5.50094450e-02, -6.91084193e-02, -1.61637252e-02,\n",
       "        -4.31749306e-02, -1.16406155e-02,  3.72140537e-01,\n",
       "         3.78100906e-02,  3.27100869e-03,  2.82766224e-03,\n",
       "        -3.24256857e-01, -1.02284157e-01,  2.66741709e-01,\n",
       "        -2.74624862e-01, -1.95574172e-01, -1.84166812e-01,\n",
       "        -4.03352273e-01,  3.63050867e-01, -2.33128749e-01,\n",
       "        -6.53786879e-01,  2.39797194e-03, -6.14903649e-01,\n",
       "        -2.70200013e-01, -4.05920228e-01,  1.74827471e-02,\n",
       "        -6.45506615e-02, -1.25592452e-01,  6.86406678e-02,\n",
       "         5.69823029e-02,  1.35448231e-01, -2.82824147e-02,\n",
       "        -1.05259540e-01, -2.03969907e-02, -1.78592504e-01,\n",
       "        -1.03035091e-01,  2.90182194e-01, -2.88851456e-01,\n",
       "        -1.78980969e-01,  3.18163489e-01, -4.35255091e-02,\n",
       "        -2.09498284e-01, -1.11784717e-01,  9.15533621e-02,\n",
       "         4.58973829e-02, -1.12298383e-01, -1.99036369e-01,\n",
       "        -1.26106450e-01, -1.35064395e-01, -2.07387139e-01,\n",
       "        -1.37806428e-01,  2.85101190e-02, -8.87996260e-02,\n",
       "        -5.32355833e-02,  2.31445234e-01, -1.53832094e-01,\n",
       "         3.80980318e-02, -3.54541893e-02, -2.25956022e-01,\n",
       "         2.25174531e-01,  6.38568209e-02, -1.11831639e+00,\n",
       "        -1.01688057e-01, -1.06187982e-01,  7.70841286e-02,\n",
       "        -4.13933133e-01,  8.80714710e-02, -1.39802821e-01,\n",
       "         2.20181592e-01,  2.11889082e-01, -2.42225134e-01]])"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lr_best.coef_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
